﻿@model IEnumerable<KRM.Core.tblTicket>
@{
    ViewBag.Title = "Email relation of order "+ Request["orderref"];
    Layout = "~/Views/Shared/_PopupLayout.cshtml";
}
<div class="box">
    <div class="box-title" style="padding: 0px 0 7px 10px;border-bottom: 1px solid #ddd;">
        <h4><i class="icon-envelope" style="color: #777"></i> Emails related to order @Request["orderref"]</h4>
</div>
    <div class="box-content" style="padding: 20px 20px 20px 10px;">
        @foreach (var ticket in Model.OrderByDescending(p => p.TicketID))
        {
                            
            <div class="box">
                <div class="box-title" style="padding: 0px 0 7px 0px;border-bottom: 1px solid #ddd;">
                    <b><a href="/ticket/viewticket/@ticket.TicketID" target="_blank">Ticket #@ticket.TicketID</a>  @ticket.Subject </b> (@ticket.Comments.Count())
@*                  <div class="actions">
					<a href="#" class="btn btn-mini content-slideUp"><i class="icon-angle-down"></i></a>
					</div>*@
                </div>
                <div class="box-content" style="padding: 20px 20px 20px 10px;border: 1px solid #ddd;margin-bottom: 20px;">
                    @foreach (var item in ticket.Comments.OrderByDescending(p => p.EmailID))
                    {
                        <div class="row-fluid ticket-comment-row">
                            <div class="span1">
                                <img alt="" src="/Upload/Avatar/@(item.SentByUser == null ? "avatar-default.jpg" : item.SentByUser.Avatar ?? "avatar-default.jpg")" onError="this.src='/upload/avatar/avatar-default.jpg';" style="text-align: center; height: 40px; max-width: 40px; background-color: #ddd !important;">
                            </div>
                            <div class="span11">
                                @{
                        var commentClass = "";
                        commentClass = item.IsIncommingEmail == true ? "ticket-comment-incomeing" : (item.IsNoteComment == true ? "ticket-comment-note" : "ticket-comment-outgoing");
                                }
                                <div class="row-fluid">
                                    <strong>@(item.SentByUser == null ? item.From : item.SentByUser.Username)</strong>
                                    <span class="ticket-comment-time">
                                        @item.Date
                                    </span>
                                </div>
                                <div class="ticket-comment @commentClass">@Html.Raw(item.Body)</div>
                                <div class="ticket-comment-attachment">
                                    <ul>
                                        @foreach (var attach in item.EmailAttachments)
                                        {
                                            <li><a target="_blank" href="\Ticket\GetFileAttachment?path=@attach.Filename">@attach.Filename.Split('\\').Last()</a></li>
                                        }
                                    </ul>
                                </div>
                            </div>
                        </div>
                    }
                </div>
            </div>
        }
    </div>
</div>

